/*	Renegade Scripts.dll
	Scripts by dudley - mp-gaming.com
	Copyright 2010 dudley

	This file is part of the Renegade scripts.dll
	The Renegade scripts.dll is free software; you can redistribute it and/or modify it 
	under the terms of the GNU General Public License as published by the Free
	Software Foundation; either version 2, or (at your option) any later
	version. See the file COPYING for more details.
	In addition, an exemption is given to allow Run Time Dynamic Linking of this code 
	with any closed source module that does not contain code covered by this licence.
	Only the source code to the module(s) containing the licenced code has to be released.
*/
#include "scripts.h"
#include "engine.h"
#include "dud_m10.h"

/*
...first objective...
Welcome back commander.
Good job rescueing the prisoners back in Slovenia.
We have discovered a large base in the eastern sector of Pakistan.
Our intel pinpointed a position for incursion which is where you are at now.
Proceed to the entrance of the Nod base and take out the Hand of Nod to cripple Nod production.
New Primary Mission Objective
Destroy the Hand of Nod
*/

void dud_m10_missionstart::Created(GameObject *obj)//this is the created event and it triggers when the object this script is attached to is created... instantly in other words
{
	Commands->Start_Timer(obj,this,5.0f,101); 
	Commands->Start_Timer(obj,this,9.0f,102);
	Commands->Start_Timer(obj,this,13.0f,103);
	Commands->Start_Timer(obj,this,17.0f,104);
	Commands->Start_Timer(obj,this,21.0f,105);
	Commands->Start_Timer(obj,this,25.0f,106);
	Commands->Start_Timer(obj,this,27.0f,107);
}
void dud_m10_missionstart::Timer_Expired(GameObject *obj, int number)//this has two options a obj and the number...lets do the .h file too, basically what needs to be in the .h
{
	if (number == 101)
	{
		Send_Message(255,204,0,"Welcome back commander.");
		Commands->Create_2D_WAV_Sound("incmsg.wav");
	}
	else if (number == 102)
	{
		Send_Message(255,204,0,"Good job rescueing the prisoners back in Slovenia.");
		Commands->Create_2D_WAV_Sound("incmsg.wav");
	}
	else if (number == 103)
	{
		Send_Message(255,204,0,"We have discovered a large base in the eastern sector of Pakistan.");
		Commands->Create_2D_WAV_Sound("incmsg.wav");
	}
	else if (number == 104)
	{
		Send_Message(255,204,0,"Our intel pinpointed a position for incursion which is where you are at now.");
		Commands->Create_2D_WAV_Sound("incmsg.wav");
	}
	else if (number == 105)
	{
		Send_Message(255,204,0,"Proceed to the entrance of the Nod base and take out the Hand of Nod to cripple Nod production.");
		Commands->Create_2D_WAV_Sound("incmsg.wav");
	}
	else if (number == 106)
	{
		Send_Message(255,204,0,"New Primary Mission Objective");
		Commands->Create_2D_WAV_Sound("objective1new.wav");//include in mix, "New Primary Objective"
	}
	else if (number == 107)
	{
		Send_Message(255,204,0,"Destroy the Hand of Nod");
		Commands->Create_2D_WAV_Sound("incmsg.wav");
	}
}

void dud_m10_honkilled::Created(GameObject *obj)
{
	killerguy = 0;
}
void dud_m10_honkilled::Killed(GameObject *obj, GameObject *shooter)
{
	if (Commands->Is_A_Star(shooter))//human player?
	{
		killerguy = shooter;
		Commands->Start_Timer(obj,this,2.5f,101);
		Commands->Start_Timer(obj,this,5.5f,102); 

	}
}

void dud_m10_honkilled::Timer_Expired(GameObject *obj, int number)
{
	if (number == 101)
	{
		char lol[250];
		sprintf(lol,"%s destroyed the Hand of Nod",Get_Player_Name(killerguy));
		Send_Message(255,204,0,lol);
		Commands->Create_2D_WAV_Sound("m00bnhn_kill0002i1evag_snd.wav");//Hand of Nod Destroyed sound EVA
	}
	else if (number == 102)
	{
		Send_Message(255,204,0,"Primary Objective Complete"); 
		Commands->Create_2D_WAV_Sound("objective1complete.wav");
	}
}

void dud_m10_honkilled::Register_Auto_Save_Variables()
{
	Auto_Save_Variable(1,5,&killerguy);
}

void dud_m10_turretscount::Created(GameObject *obj)
{
	count = 0;//first we create our var and assign 0 to it, cos 0 turrets are killed...
	target = Get_Int_Parameter("TargetAmount");//how many kills we wait for to trigger on...
	msg = Get_Int_Parameter("Message");//what msg we gonna listen for
}
void dud_m10_turretscount::Register_Auto_Save_Variables()
{
	Auto_Save_Variable(1,5,&count);
	Auto_Save_Variable(1,5,&msg);
	Auto_Save_Variable(1,5,&target);//we gotto save their states....
}
void dud_m10_turretscount::Custom(GameObject *obj, int message, int param, GameObject *sender)//we gonna send a message to this script when a turret is killed...
{
	if (message == msg)//if the message sent is the msg we asked for
	{
		if (param == 1)//we always send param 1
		{
			count++;//register a kill and increment
			if (count == target) //did count hit limit?
			{
				int red = Get_Int_Parameter("Red");
				int green = Get_Int_Parameter("Green");
				int blue = Get_Int_Parameter("Blue");//ask input for the colorcode
				const char *snd = Get_Parameter("Sound");//ask input for what sound to play
				const char *themsg = Get_Parameter("MessageDisplay");
				Commands->Create_2D_WAV_Sound(snd);//create the sound input
				Send_Message(red,green,blue,themsg);//do the message with the inputted coloring and input at themsg
			}
		}
	}
}

void dud_m10_unlockmammy::Custom(GameObject *obj, int message, int param, GameObject *sender)
{
	if (message == 1000)
	{
		if (param == 1)
		{
			Remove_Script(obj,"M00_Disable_Transition");
			Remove_Script(obj,"M00_Damage_Modifier_DME");
		}
	}
}


ScriptRegistrant<dud_m10_unlockmammy> dud_m10_unlockmammy_Registrant("dud_m10_unlockmammy","");
ScriptRegistrant<dud_m10_turretscount> dud_m10_turretscount_Registrant("dud_m10_turretscount","TargetAmount=3:int,Message=1000:int,Red=255:int,Green=204:int,Blue=0:int,Sound=bla:string,MessageDisplay=msglol:string");
ScriptRegistrant<dud_m10_honkilled> dud_m10_honkilled_Registrant("dud_m10_honkilled","");
ScriptRegistrant<dud_m10_missionstart> dud_m10_missionstart_Registrant("dud_m10_missionstart","");